package com.ciaojian.worker.controller;

import com.ciaojian.core.model.UserAppraise;
import com.ciaojian.core.util.Result;
import com.ciaojian.worker.model.param.SaveUserLabelDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author oxiny
 */
@Api(tags = "用户模块: 用户标签")
@Validated
@RestController
@RequestMapping("/user/label")
public class UserAppraiseController {

    @ApiOperation("获取用户标签")
    @GetMapping("/{userId}")
    public Result get(@PathVariable Integer userId) {
        UserAppraise userAppraise = new UserAppraise().selectById(userId);
        return Result.ok(userAppraise);
    }

    @ApiOperation("保存用户标签")
    @PostMapping
    public Result save(@RequestBody @Validated SaveUserLabelDTO param) {
        UserAppraise userAppraise = param.convert();
        return Result.save(userAppraise.insertOrUpdate());
    }
}
















